import request from '@/utils/request'

// 注册接口
// 命名规范：模块名功能服务 - userRegisterService
// export const userRegisterService = ({ username, password, repassword }) => {
//   return request.post('/api/reg', { username, password, repassword })
// }
// 简写 - 把 {} 和 return 省略
export const userRegisterService = ({ username, password, repassword }) => 
  request.post('/api/reg', { username, password, repassword })


// 登录接口
export const userLoginService = ({ username, password }) => 
  request.post('/api/login', { username, password })


// 获取用户的基本信息
export const userGetInfoService = () => request.get('/my/userinfo')

// 更新用户的基本信息
export const userUpdateInfoService = (data) => request.put('/my/userinfo', data)

// 更新用户的头像
export const userUpdateAvatarService = avatar => request.patch('/my/update/avatar', { avatar })

// 重置密码
export const userUpdatePwdService = ({ old_pwd, new_pwd, re_pwd }) =>
  request.patch('/my/updatepwd', { old_pwd, new_pwd, re_pwd })